<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="sec"
	uri="http://www.springframework.org/security/tags"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<sec:authentication property="principal" var="currentPrincipal"
	scope="page" />

<fmt:setBundle basename="ApplicationMessage" />
<fmt:setLocale value="zh_CN" />

<!DOCTYPE html>
<html lang="zh-CN">
<head>

<%@ include file="/WEB-INF/include/meta.jsp"%>
<%@ include file="/WEB-INF/include/css.jsp"%>

</head>

<body class="ms-theme-blue">

	<%@ include file="/WEB-INF/include/header.jsp"%>

	<%@ include file="/WEB-INF/include/menu.jsp"%>
	<div class="container-fluid ms-container has-ms-sidemenu">

		<ol class="ms-breadcrumb breadcrumb">
			<li class="active">优惠券批次&nbsp;&nbsp;-&nbsp;&nbsp;详情</li>
			<li class="no-before pull-right" style="min-width: 65px;">
            <a onclick="window.history.back();"><i class="glyphicon glyphicon-arrow-left"></i>&nbsp;&nbsp;返回</a>
          </li>
		</ol>

		<div class="col-xs-2 x-panel-layout-left no-horizontal-padding">
			<%@ include file="/WEB-INF/include/submenu.jsp"%>
		</div>

		<div class="ms-content-layout ">
			<div class="form-horizontal ms-form form-personal-info">
				<div class="block-heading">
					<h5>基本信息</h5>
				</div>
				<div class="form-group ms-form-group">

					<label class="control-label col-xs-2" style="width: 15%;">优惠券名称：</label>
					<div class="col-xs-2">
						<p class="form-control-static">${couponBatch.templateName}</p>
					</div>
					<label class="control-label col-xs-2" style="width: 15%;">批次名称：</label>
					<div class="col-xs-2">
						<p class="form-control-static">${couponBatch.name}</p>
					</div>

				</div>
				<div class="form-group ms-form-group">

					<label class="control-label col-xs-2" style="width: 15%;">本次发放总数：</label>
					<div class="col-xs-2">
						<p class="form-control-static">${couponBatch.amount}</p>
					</div>
					<label class="control-label col-xs-2" style="width: 15%;">已使用数：</label>
					<div class="col-xs-2">
						<p class="form-control-static">${couponBatch.usedAmount}</p>
					</div>

				</div>
				<div class="form-group ms-form-group">

					<label class="control-label col-xs-2" style="width: 15%;">已认领数：</label>
					<div class="col-xs-2">
						<p class="form-control-static">${couponBatch.claimedAmount}</p>
					</div>
					<label class="control-label col-xs-2" style="width: 15%;">截止日类型：</label>
					<div class="col-xs-2">
						<p class="form-control-static">${couponBatch.expireType.description}</p>
					</div>



				</div>
				<c:if test="${couponBatch.expireType eq 'FIXED_DAYS' }">
					<div class="form-group ms-form-group">
						<label class="control-label col-xs-2" style="width: 15%;">开始日期：</label>
						<div class="col-xs-2">
							<p class="form-control-static">
								<fmt:formatDate value="${couponBatch.effectiveStartDate}"
									pattern="yyyy-MM-dd HH:mm:ss" />
							</p>
						</div>
						<label class="control-label col-xs-2">截止日期：</label>
						<div class="col-xs-2">
							<p class="form-control-static">
								<fmt:formatDate value="${couponBatch.effectiveEndDate}"
									pattern="yyyy-MM-dd HH:mm:ss" />
							</p>
						</div>
					</div>
				</c:if>
				<div class="block-heading">
					<h5>优惠券列表</h5>
				</div>


				<table class="table table-hover ms-table">
					<thead>
						<tr>
							<th class="text-center">券码</th>
							<th class="text-center">开始日期</th>
							<th class="text-center">截止日期</th>
							<th class="text-center">状态</th>
							<th class="text-center">用户</th>
							<th class="text-center">实际抵扣金额</th>
							<th class="text-center">操作</th>
						</tr>
					</thead>
					<tbody>

						<c:forEach var="coupon" items="${coupons}">
							<tr>
								<td class="text-center">${coupon.code}</td>
								<td class="text-center"><fmt:formatDate
										value="${coupon.effectiveStartDate}"
										pattern="yyyy-MM-dd HH:mm:ss" /></td>
								<td class="text-center"><fmt:formatDate
										value="${coupon.effectiveEndDate}"
										pattern="yyyy-MM-dd HH:mm:ss" /></td>
								<td class="text-center"><span
									class="label label-${coupon.status.css}">${coupon.status.description}</span></td>
								<td class="text-center">${coupon.userName}</td>
								<td class="text-center"><fmt:formatNumber type="percent" maxFractionDigits="2"  pattern="0.00" value="${coupon.amount/100}" />元</td>
								<td class="text-center"><c:choose>
										<c:when
											test="${coupon.status.isUnclaimed() and (currentPrincipal.admin or currentPrincipal.root)}">
											<a href="${ctx.host}/coupon-batch/${couponBatch.id}/coupons/${coupon.id}/identify" data-target="#coupon-batch-identify"
												data-toggle="modal" title="指定用户">指定用户</a>
										</c:when>
										<c:otherwise>无</c:otherwise>
									</c:choose></td>
							</tr>
						</c:forEach>
					</tbody>
					<tfoot>
						<tr>
							<td colspan="9" class="no-vertical-padding">
								<div class="pull-left">
									<jsp:include page="/WEB-INF/include/page.jsp">
										<jsp:param name="url" value="${couponBatch.id}" />
									</jsp:include>
								</div>
							</td>
						</tr>
					</tfoot>
				</table>


			</div>
		</div>





	</div>

	<%@ include file="/WEB-INF/include/footer.jsp"%>
	<%@ include file="/WEB-INF/include/script.jsp"%>
	<d:resource root="${ctx.resource}/build" type="script"
		src="js/page/encommerce/coupon/coupon-batch-view.js">
		<script type="text/javascript">
			require([ 'page/encommerce/coupon/coupon-batch-view' ], function(
					page) {
				page.init()
			})
		</script>
	</d:resource>
</body>
</html>